package miku.firstgame.entity
{
	import com.saia.starlingPunk.SPEntity;
	import com.saia.starlingPunk.SPMask;

	import starling.animation.Transitions;
	import starling.animation.Tween;
	import starling.core.Starling;
	import starling.display.Image;
	import starling.textures.Texture;

	public class FireEntity extends SPEntity
	{
		[Embed(source = "media/fire.png")]
		public const ui:Class;

		public function FireEntity()
		{
			super(0, 0, "fire");
		}

		override public function added():void
		{
			super.added();
			setupGraphic();
//			
//			Starling.juggler.delayCall(explode, 2.0); 

			var hideTween:Tween = new Tween(this, 1.0, Transitions.EASE_IN);
			hideTween.animate("alpha", 0.0);
			hideTween.onComplete = onTweenComplete;
			Starling.juggler.add(hideTween); //自动移除还是手动移除
		}

		private function onTweenComplete():void
		{
			this.world.remove(this);
		}

		private function setupGraphic():void
		{
			var image:Image = new Image(Texture.fromBitmap(new ui()));
			addChild(image);
		}

		override public function removed():void
		{
			removeChildren(0, -1, true);
			super.removed();
		}

		override public function update():void
		{
			super.update();
			//			updateMovement(); 
			//			updateInput();
			//			updateCollision();

		}
	}
}
